import request from '../utils/request';
import ajax from '../utils/ajax';



//----------------------------------------------------------------------------------------------------------------------
/** 用户模块*/
/** 1. 根据用户id获取用户
 * @Param Id 用户id
 */
export const queryUserById = ({ Id }) => ajax('/user', { Id });

/** 2. 添加用户 */
export const addUser = ({

                            classId = '',
                            collegeId = '',
                            deptId = '',
                            designation = '',
                            education = '',
                            idCard = '',
                            image = '',
                            inTime = '',
                            joinTime = '',
                            name = '',
                            nation = '',
                            outTime = '',
                            password = '',
                            phone = '',
                            place = '',
                            position = '',
                            remark = '',
                            sex = '',
                            userId = ''
                        }) => ajax('/user', {
    classId,
    collegeId,
    deptId,
    designation,
    education,
    idCard,
    image,
    inTime,
    joinTime,
    name,
    nation,
    outTime,
    password,
    phone,
    place,
    position,
    remark,
    sex,
    userId
}, 'POST');

/** 3. 根据id修改用户信息 */
export const updateUser = ({

                               userId = '',
                               classId = '',
                               collegeId = '',
                               deptId = '',
                               designation = '',
                               education = '',
                               idCard = '',
                               image = '',
                               inTime = '',
                               joinTime = '',
                               name = '',
                               nation = '',
                               outTime = '',
                               password = '',
                               phone = '',
                               place = '',
                               position = '',
                               remark = '',
                               sex = ''
                           }) => ajax('/user', {
    classId,
    collegeId,
    deptId,
    designation,
    education,
    idCard,
    image,
    inTime,
    joinTime,
    name,
    nation,
    outTime,
    password,
    phone,
    place,
    position,
    remark,
    sex,
    userId
}, 'PUT');

/** 4. 根据用户id删除用户 */
export const deleteUserById = ({ Id }) => ajax('/user', { Id }, 'DELETE');

/** 5. 管理员根据学号修改用户密码 */
export const updatePasswordByUsername = ({ username, password }) => ajax('/user/UpdatePassByAdmin', {
    username,
    password

}, 'POST');

/** 6. 根据姓名、性别、民族、班级编号、部门编号分页查询用户信息 */
export const queryUsers = ({ name = '', sex = '', nation = '', classId = '', deptId = '', current, size }) => ajax('/user/selectByother', {
    name,
    sex,
    nation,
    classId,
    deptId,
    current,
    size

});

/** 7. 批量删除用户 */
export const deleteUsers = ({ list = [] }) => ajax('/user/list', { list }, 'DELETE');


//----------------------------------------------------------------------------------------------------------------------
/** 班级模块 */
/** 1. 获取班级列表 */
export const queryClazzs = () => ajax('/clazz/list', {}, 'GET');

/** 2. 分页获取班级列表 */
export const queryClazzsByPage = ({ current = 1, size = 6 }) => ajax('/clazz/clazzPage', { current, size }, 'GET');

//******************************************
/** 3. 根据条件分页查询 */
export const queryClazzsByPageAndCondition = ({}) => ajax('/clazz/foundClazzPage', {}, 'GET');
//******************************************

/** 4. 新增班级 */
export const addClazz = ({ name = '', collegeId = '' }) => ajax('/clazz/insertClazz', { name, collegeId }, 'POST');

/** 5. 删除班级 */
export const deleteClazz = ({ clazzId = '' }) => ajax('/clazz/deleteClazz', { clazzId }, 'DELETE');

/** 6. 修改班级信息 */
export const updateClazz = ({ clazzId = '', name, collegeId }) => ajax('/clazz/putClazz', {
    clazzId,
    name,
    collegeId
}, 'PUT');


//----------------------------------------------------------------------------------------------------------------------
/** 院系模块 */
/** 1.分页查询院系 */
export const queryColleges = ({ current = 1, size = 7 }) => ajax('/college/page', { current, size }, 'GET');

/** 2.通过id查询学院 */
export const queryCollegeById = ({ collegeId }) => ajax('/college', { collegeId }, 'GET');

/** 3.添加学院信息 */
export const addCollege = ({ name = '' }) => ajax('/college', { name }, 'POST');

/** 4.修改学院信息 */
export const updateCollege = ({ collegeId = '', name = '' }) => ajax('/college', { collegeId, name }, 'PUT');

/** 5.删除学院信息 */
export const deleteCollege = ({ collegeId = '',name = '' }) => ajax('/college', { collegeId,name }, 'DELETE');

/** 6.根据学院id查询班级 */
export const queryClazzByCollegeId = ({ collegeId = ''}) => ajax('/clazz/getListByCollegeId',{collegeId}, 'GET');

//----------------------------------------------------------------------------------------------------------------------
/** 党支部模块 */
/** 1. 分页查询党支部 */
export const queryDeptByPage = ({ current = 1, size = 7 }) => ajax('/dept/deptPage', { current, size }, 'GET');

/** 2. 通过Id查询党支部 */
export const queryDeptById = ( deptId = '' ) => ajax('/dept/selectDeptId', deptId , 'GET');

/** 3. 添加党支部 */
export const addDept = ({ name, parentId, info }) => ajax('/dept/insertDept', { name, parentId, info }, 'POST');

/** 4. 修改党支部 */
export const updateDept = ({ deptId, name, parentId, info }) => ajax('/dept/updateDept', {
    deptId,
    name,
    parentId,
    info
}, 'PUT');

/** 5. 根据id删除支部 */
export const deleteDept = ({ deptId }) => ajax('/dept/deleteDept', { deptId }, 'DELETE');


//----------------------------------------------------------------------------------------------------------------------
/** 管理员模块 */
/** 1.管理员登录 */
export const loginAdmin = ({ account, password }) => ajax('/admin/loginAdmin', { account, password }, 'POST');


/**
 * 2. 分页查询管理员
 * @Param  用户的
 * @Param current 页码
 * @Param size 页面大小
 */
export const queryAdmins = ({ current, size}) => ajax('/admin/adminPage', { current, size }, 'GET');

/** 3. 添加管理员？？？？？？？？？？？？？？？*/
export const addAdmin = ({account,password}) => ajax('/admin/insertAdmin',{account,password}, 'POST');

/** 4. 修改密码 */
export const updatePassword = ({adminId,account, password }) => ajax('/admin/editPwd', {
    adminId,
    account,
    password
}, 'PUT');

/** 5. 删除管理员 */
export const deleteAdmin = ({ adminId }) => ajax('/admin/deleteAdmin', { adminId }, 'DELETE');

/** 6. 批量删除管理员 */
export const deleteAdmins = ({ list }) => ajax('/admin/deleteList',  list , 'DELETE');


//----------------------------------------------------------------------------------------------------------------------
/** 试题模块 */
/** 1. 分页查询题目_只有答案类型 */
export const queryQuestionByPage = ({ current, size }) => ajax('/question/questionByPage', {current,size}, 'GET');

/**
 * 2. 根据题目id和类型查找题目_分页
 * @param id
 * @param type
 * @param current
 * @param size
 * @returns {*|Promise|Promise<unknown>}
 */
export const queryQuestionPage = ({ id, type, current, size}) => ajax('/question/QuestionPageByIdAndType', {
    id,
    type,
    current,
    size
}, 'GET');

/** 3. 通过题目的id集合返回题的内容 */
export const queryQuestionByIdList = ({ ids }) => ajax('/question/questionByIdList', ids, 'POST');

/** 4. 添加题目 */
export const addQuestion = ({ type, title, items, analyze, correctArray, score }) => ajax('/question/insert', {
    type,
    title,
    items,
    analyze,
    correctArray,
    score
}, 'POST');

/** 5. 编辑试题 */
export const updateQuestion = ({ id, type, title, items, analyze, correctArray, score }) => ajax('/question/edit', {
    id,
    type,
    title,
    items,
    analyze,
    correctArray,
    score
}, 'POST');

/** 6. 通过Id批量删除题目 */
export const deleteQuestion = ({questionList}) => ajax('/question/list',  questionList , 'DELETE');


//----------------------------------------------------------------------------------------------------------------------
/** 试卷模块 */
/** 1. 添加试卷 */
export const addExamPage = ({ exampageId, exampageName, createTime, startTime, endTime, adviceTime, choice, multChoices, judge, pack, bigQuestions }) => ajax('/exampage', {
    exampageId,
    exampageName,
    createTime,
    startTime,
    endTime,
    adviceTime,
    choice,
    multChoices,
    judge,
    pack,
    bigQuestions
}, 'POST');

/** 2. 修改试卷信息 */
export const updateExamPage = ({ exampageId, exampageName, createTime, startTime, endTime, adviceTime, choice, multChoices, judge, pack, bigQuestions }) => ajax('/exampage/update', {
    exampageId,
    exampageName,
    createTime,
    startTime,
    endTime,
    adviceTime,
    choice,
    multChoices,
    judge,
    pack,
    bigQuestions
}, 'POST');

/** 3. 通过id查询试卷，不含答案 */
export const queryExamPage = ({ id }) => ajax('/exampage/select', { id }, 'GET');

/** 4. 通过id查询试卷 存在答案 */
export const queryExamPageAnswer = ({ id }) => ajax('/exampage/select', { id }, 'GET');

/** 5. 分页查询试卷信息 */
export const queryExamPageByPage = ({ current, size }) => ajax('/exampage/page', { current, size }, 'GET');

/** 6. 根据id删除试卷 */
export const deleteExamPages = ({ list }) => ajax('/exampage', { list }, 'DELETE');

/** 7. 随机生成试卷 */
export const randomExampage = ({ choiceNum, multipleChoiceNum, judgeNum, packNum, bigQuestionNum, choiceScore, multipleChoiceScore, judgeScore, packScore, bigQuestionScore }) => ajax('/exampage/random', {
    choiceNum,
    multipleChoiceNum,
    judgeNum,
    packNum,
    bigQuestionNum,
    choiceScore,
    multipleChoiceScore,
    judgeScore,
    packScore,
    bigQuestionScore
}, 'POST');


//----------------------------------------------------------------------------------------------
/**
 *
 *  答题卡模块
 * */

/** 1.报名参加考试(添加考试人员)*/
export const userJoinExam = (examId,list) => ajax('/answer/userJoinExam',{examId,list},'POST');

/** 2.根据试卷id返回这场考试的考生信息*/
export const getAnswersByExamId = ({examId}) => ajax('/answer/getAnswersByExamId',{examId},'GET');

/** 3.教师改卷*/
export const teacherJudge = ({answerId,bigQuestions,bigQuestionsScore,choice,exampageId,judge,multChoices,otherScore,pack,status,userId}) => ajax('/answer/teacherJudge',
    {
        answerId,
        bigQuestions,
        bigQuestionsScore,
        choice,
        exampageId,
        judge,
        multChoices,
        otherScore,
        pack,
        status,
        userId
    },'POST');

/** 4.根据答题卡id查询答题卡*/
export const getAnswerByAnswerId = ({answerId}) => ajax('/answer/answer',{answerId},'GET');

/** 5.根据用户id和考试id查询答题卡 */
export const getAnswerByUserIdAndExamId = ({examId,userId}) => ajax('/answer/getAreTheExam',{examId,userId},'GET');

